﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Stauffware.Common.Core
{
	//#################################################################################
	/// <summary>
	/// Parser for signed ulong values (System.Int64).
	/// </summary>

	public class Int64Parser : IntegerParser<long, Int64Parse>
	{ 
		/// <summary>
		/// Constructs a parser that uses NumberParseOptions.DefaultParseOptions.
		/// </summary>
		public Int64Parser ( ) : base(DefaultParseOptions, null) { }

		/// <summary>
		/// Constructs a parser.
		/// </summary>
		/// <param name="options">parsing options</param>
		public Int64Parser (NumberParseOptions options) : base(options, null) { }

		/// <summary>
		/// Constructs a parser that uses NumberParseOptions.DefaultParseOptions.
		/// </summary>
		/// <param name="ifp">formatting info, or null</param>
		public Int64Parser (IFormatProvider ifp) : base(NumberParseOptions.None, ifp) { }

		/// <summary>
		/// Constructs a parser.
		/// </summary>
		/// <param name="options">parsing options</param>
		/// <param name="ifp">formatting info, or null</param>
		public Int64Parser (NumberParseOptions options, IFormatProvider ifp) : base(options, ifp) { }

		/// <summary>
		/// Gets the maximum number of digits (base 10) that a number can have.
		/// </summary>
		protected override int MaxDigits { get { return 20; } }

		/// <summary>
		/// Gets the maximum number of digits that can appear in an exponent.
		/// </summary>
		protected override int MaxExponentDigits { get { return 2; } }

		/// <summary>
		/// Gets whether this parser's target type is signed.
		/// </summary>
		protected override bool Signed { get { return true; } }

	//	/// Creates a Parse object of the proper class for this Parser.
	//	protected override IntegerParse<long> CreateParseObject ()
	//	{ return new Int64Parse(); }

		/// Attempts a parse of a normalized integer string.  (see IntegerParser.TryParse)
		protected override bool TryParse (string str, out long value)
		{ return long.TryParse(str, out value); }

	}

	//=================================================================================
	/// <summary>
	/// Encapsulates the result of trying to parse a string into an long value.
	/// </summary>

	public class Int64Parse : IntegerParse<long>
	{
	}

	//#################################################################################
	/// <summary>
	/// Parser for unsigned ulong values (System.UInt64).
	/// </summary>

	public class UInt64Parser : IntegerParser<ulong, UInt64Parse>
	{
		/// <summary>
		/// Constructs a parser that uses NumberParseOptions.DefaultParseOptions.
		/// </summary>
		public UInt64Parser ( ) : base(DefaultParseOptions, null) { }

		/// <summary>
		/// Constructs a parser.
		/// </summary>
		/// <param name="options">parsing options</param>
		public UInt64Parser (NumberParseOptions options) : base(options, null) { }

		/// <summary>
		/// Constructs a parser that uses NumberParseOptions.DefaultParseOptions.
		/// </summary>
		/// <param name="ifp">formatting info, or null</param>
		public UInt64Parser (IFormatProvider ifp) : base(NumberParseOptions.None, ifp) { }

		/// <summary>
		/// Constructs a parser.
		/// </summary>
		/// <param name="options">parsing options</param>
		/// <param name="ifp">formatting info, or null</param>
		public UInt64Parser (NumberParseOptions options, IFormatProvider ifp) : base(options, ifp) { }

		/// <summary>
		/// Gets the maximum number of digits (base 10) that a number can have.
		/// </summary>
		protected override int MaxDigits { get { return 20; } }

		/// <summary>
		/// Gets the maximum number of digits that can appear in an exponent.
		/// </summary>
		protected override int MaxExponentDigits { get { return 2; } }

		/// <summary>
		/// Gets the maximum number of digits that can appear in an exponent.
		/// </summary>
		/// Gets whether this parser's target type is signed.
		protected override bool Signed { get { return false; } }

	//	/// Creates a Parse object of the proper class for this Parser.
	//	protected override IntegerParse<ulong> CreateParseObject ()
	//	{ return new UInt64Parse(); }

		/// Attempts a parse of a normalized integer string.  (see IntegerParser.TryParse)
		protected override bool TryParse (string str, out ulong value)
		{ return ulong.TryParse(str, out value); }
	}

	//=================================================================================
	/// <summary>
	/// Encapsulates the result of trying to parse a string into a ulong value.
	/// </summary>

	public class UInt64Parse : IntegerParse<ulong>
	{
	}

	//#################################################################################
}
